package problem1576;

//1576.替换所有的问号
//https://leetcode.cn/problems/replace-all-s-to-avoid-consecutive-repeating-characters/

class Solution {
    public String modifyString(String s) {
        int n = s.length();
        char[] str = s.toCharArray();
        for(int i = 0; i<n; i++) {
            if(str[i] == '?') {
                for(char ch = 'a'; ch <= 'z'; ch++) {
                    if((i-1 < 0 || str[i-1] != ch) && (i+1 >= n || str[i+1] != ch)) {
                        str[i] = ch;
                        break;
                    }
                }
            }
        }
        return new String(str);
    }
}